Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
NodeJS not showing full object, only [Object], for response

When sending all documents from the MondoDB database I'm getting the response

data: { list: [ [Object], [Object] ] }

This is the correct number of documents, and they are objects, but I want to know how I can display the entire document, including nested objects, not just the [Object]. How is this possible? Here's my code:

Doc.find({})
            .then((list) => {
                let listToSend = [];

                // push the response data to the array
                for (let i = 0; i < list.length; i++) {
                    listToSend.push(list[i]);
                }

                // send the list once all documents are pushed
                res.send(({ data: listToSend }));
            })
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If you want to increase the depth of the inspection output (the default is 2) you can manually call the inspect function (here I used 6 as example):

import { inspect } from 'util'

console.log(inspect(myObject, { depth: 6 }))

Or if you want that to happen all the time by default, you can set the defaultOptions:

import { inspect } from 'util'

inspect.defaultOptions.depth = 6
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use JSON.stringify, and get some nice formatting

console.log(JSON.stringify(myObject, null, 4));

console.log(JSON.parse(JSON.stringify(myObject)));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda